package com.sxhnpg.util;

import java.security.MessageDigest;

import sun.misc.BASE64Encoder;

public class DigestUtil {

	public static String md5Digest(String msg)throws Exception{
		MessageDigest md=MessageDigest.getInstance("MD5");//加密
		byte[]bts=md.digest(msg.getBytes());//方一个byte[]进去
		//System.out.println(new String(bts));
		//采用BASE64算法处理
		BASE64Encoder encoder=new BASE64Encoder();
		return encoder.encode(bts);
	}
	public static void main(String[] args) throws Exception {
		System.out.println(md5Digest("dsdfdsf"));
		System.out.println(md5Digest("dsdfdsfddddddd"));
	}
}
